<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Users_lib {

    private $CI;
    private $userdata=array();
    function __construct() {
        
        $this->CI = & get_instance();
        $this->CI->load->model('users/users_model');
        $this->userdata=$this->CI->session->all_userdata();
    }

    function is_login() {
        return isset($this->userdata['logged_in'])?$this->userdata['logged_in']:FALSE;
    }

    function get_user_id(){
        return isset($this->userdata['user_id'])?$this->userdata['user_id']:FALSE;
    }

    function get_fullname(){
        if($this->get_user_id()){
            $params=array(
                'user_id'=>$this->get_user_id()
                    );
            $userprofile=$this->CI->users_model->users_get_profile($params);
            if(!empty($userprofile)){
				return trim($userprofile->firstname).' '.trim($userprofile->lastname);
            }
        }
        return 'No Name';
    }

}
